// packageA/pages/ziliao.js
var t = getApp(),
  a = t.requirejs("core"),
  s = t.requirejs("wxParse/wxParse");
Page({

  /**
   * 页面的初始数据
   */
  data: {
			 background:'../static/yingyezhizhao.png',
			  link: '',
			  tel: '',
			  category: '',
			 	company: '',
			 	license: '',
			 	address: '',
  },
		Inputcompany(e){
		      this.setData({
		        company: e.detail.value
		      })
		    // console.log(this.data.company);
		  },
		Inputlink(e){
					this.setData({
						link: e.detail.value
					})
				// console.log(this.data.link);
			},
		Inputtel(e){
					this.setData({
						tel: e.detail.value
					})
				// console.log(this.data.tel);
			},
		Inputcategory(e){
					this.setData({
						category: e.detail.value
					})
				// console.log(this.data.category);
			},
		Inputlicense(e){
					this.setData({
						license: e.detail.value
					})
				// console.log(this.data.license);
			},
		Inputaddress(e){
					this.setData({
						address: e.detail.value
					})
				// console.log(this.data.address);
			},
		chooseImageTap2: function (e) {
				var id1 = a.pdata(e).id1;
				this.upload1(this, id1, 'chat_pic1');
			},
	upload1: function (that, field, n) {
	    var _this = this;
	    wx.showActionSheet({
	      itemList: ['从相册中选择', '拍照'],
	      itemColor: "#f7982a",
	      success: function (res) {
	        if (!res.cancel) {
	          if (res.tapIndex == 0) {
	            _this.chooseWxImage1('album', that, field, n)
	          } else if (res.tapIndex == 1) {
	            _this.chooseWxImage1('camera', that, field, n)
	          }
	  
	        }
	      }
	    })
	  },
		chooseWxImage1: function (type_, that, field, n) {
		    var _this = this,
		      site = getApp().siteInfo,
		      url = site.siteroot + '?i=' + site.uniacid + '&t=undefined&v=' + site.version + '&from=wxapp&c=entry&a=wxapp&do=index_uploadFile&path=' + n + '&m=yb_mingpian&sign=5201314';
		    wx.chooseImage({
		      sizeType: ['original', 'compressed'],
		      sourceType: [type_],
		      success: function (res) {
		  
		        console.log(res)
		        wx.uploadFile({
		          url: url,
		          filePath: res.tempFilePaths[0],
		          name: 'file_upload',
		          success: function (res) {
		  
		            if (res.data != null && res.data != '') {
		              console.log(res.data)
		              that.setData({
		                license: res.data,
		              })
		              // that.bindconfirm();
		            } else {
		              a.error('上传失败，请重试')
		            }
		          }
		        })
		  
		      }
		    })
		  },
			upMycard:function(){
			    var o = this
			    console.log(o.data.link);
			    console.log(o.data.tel);
			    console.log(o.data.address);
				console.log(o.data.company);
				console.log(o.data.category);
				console.log(o.data.license);
			    a.get("Card/CompanyApply",{
			      uid: t.getCache("userinfo").uid,
			      link: o.data.link,
			      tel: o.data.tel,
			      address: o.data.address,
				  company: o.data.company,
				  category: o.data.category,
				  license: o.data.license,
			      // head_photo: o.data.head_photo
			    },function (res) {
			      console.log(res)
			      wx.showToast({
			        title: res.info,
			        icon: 'none',
			      })
			      // setTimeout(function () {
			      wx.redirectTo({
							url: '/yb_mingpian/pages/ruzhu/ruzhu',
						})
			      // }.bind(o), 200)
			      console.log(res)
			    })
			  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})